<?php
/*
	我的下线
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$return['setting']=$this->plugin_setting('page_setting');
	$levels=array();
	$return['levels']=$levels;
	$return['member']=model('core/member')->detail($_SESSION['uid'],array('nickname','avatar'));
	$return['member_num']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'fromuser'=>$_SESSION['uid']));
	$return['params']=array('page'=>1,'level'=>1);
	$return['psize']=20;
	$return['list']=array();
	set_html('title','受邀好友');
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$agent_ids=$_SESSION['uid'];
	if(!$agent_ids){
		exi('none');
	}
	$params['fromuser']=$agent_ids;
	$psize=20;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'createtime desc',
	);
	$list=pdo_getlist('core_members',$parameter);
	if(!$list){
		exi('none');
	}
	$goods_opentime=$this->setting['goods_opentime']?:0;
	foreach($list as &$item){
		$item['member']=cfc('core')->member_show($item['id']);
		$item['createtime']=date('Y-m-d H:i:s',$item['createtime']);
		$item['member_num']=pdo_count('core_members',array('uniacid'=>$_SESSION['uniacid'],'fromuser'=>$item['id']));
		$member=pdo_get('jy_weishop_member',array('mid'=>$item['id'],'uniacid'=>$_SESSION['uniacid'],'merchid'=>0),array('level','viptime'));
		$item['leveltitle']=pdo_getcolumn('jy_weishop_member_level',array('uniacid'=>$_SESSION['uniacid'],'id'=>$member['level']),'title');
		$item['leveltitle']=$item['leveltitle']?:'普通会员';
		$feelog=$this->get('feelog',array('createtime >'=>$goods_opentime,'uniacid'=>$_SESSION['uniacid'],'type'=>1,'jie_mid'=>0,'mid'=>$item['id']));
		if($feelog['id']){
			$item['yaotitle']=$isfeelog['status']?'已参与新人体验':'新人体验订单已完成';
		}else{
			$item['yaotitle']='未参与新人体验';
		}
		$item['feelog']=$feelog;
	}
	exi($list);
}
?>